package com.shunwang.errors.engine.core;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.shunwang.errors.engine.util.ThrowableUtil;

/**
 * @author hadoop20
 * @version 1.0
 * @created 19-10-2011 10:40:50
 */
public class Mapper {
	
	private Logger logger =  LoggerFactory.getLogger(Mapper.class);
	
	private Map<String,Mapping> mapper = new HashMap<String,Mapping>();

	public Mapping getMapping(String fullName){
		return mapper.get(fullName);
	}

	public Mapping getMapping(Throwable throwable){
		return this.getMapping(ThrowableUtil.getFirstThrowable(throwable));
	}

	public void setMapping(String fullName,Mapping mapping){
		if(mapper.containsKey(fullName)){
			logger.debug("mapper contains fullName");
		}else{
			mapper.put(fullName, mapping);
		}
	}

}